package com.sc.oa.action;

import java.io.Serializable;
import java.util.List;

import com.opensymphony.xwork2.ActionContext;
import com.sc.oa.base.BaseAction;
import com.sc.oa.entity.SysMenu;


public class MenuAction extends BaseAction<SysMenu>{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1827148025244890035L;
	private Integer parentId;
	//显示所有的菜单
	public String menuList(){
		
		List<SysMenu> menu = (List<SysMenu>) menuservice.findAll();
		ActionContext.getContext().put("m", menu);
		return "menulist";
	}
	//添加菜单
	public String addMenu(){
		System.out.println("----->addMenu");
		model.setParent(menuservice.getById(parentId));
		menuservice.save(model);
		return "toList";
	}
	//	编辑菜单
	public String editMenu(){
		System.out.println("----->:update");
		model.setParent(menuservice.getById(parentId));
		menuservice.update(model);
		return "toList";
	}
	//删除菜单
	public String delMenu(){
		Integer id = model.getMenuId();
		menuservice.deleteByIds(id);
		return "toList";
	}
	public Integer getParentId() {
		return parentId;
	}
	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}
	

}
